import pandas as pd
df = pd.read_csv('merge.csv')
#top_10_sales.to_csv('kh_demand.csv', index=False)
def calculate_top_sales_per_brand(df, category):
    brand_sales = df[df['hplx'] == category].groupby('cppp')['jz'].sum().reset_index()
    top_sales = brand_sales.sort_values(by='jz', ascending=False).head(10)
    return top_sales
top_sales_kf = calculate_top_sales_per_brand(df, '矿粉')
print("矿粉各品牌总销量:")
print(top_sales_kf)

# 计算北用品牌的总销量前十的产品
top_sales_sn = calculate_top_sales_per_brand(df, '水泥')
print("水泥各品牌总销量:")
print(top_sales_sn)